package com.dy.org.dto;

import com.dy.org.domain.Employee;
import com.dy.org.domain.Shop;
import lombok.Builder;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

@Data
public class ShopDto {
    @NotBlank(message = "用户名不能为空")
    private String name;
    @NotBlank(message = "电话不能为空")
    private String tel;
    @NotBlank(message = "地址不能为空")
    private String address;
    private String logo;
    @Valid
    private EmpDto admin;

    public Shop getShop(){
        return Shop.builder()
                .name(this.name)
                .tel(this.tel)
                .address(this.address)
                .logo(this.logo)
                .build();
    }


    public Employee getEmp(){
        return Employee.builder()
                .username(this.admin.getUsername())
                .phone(this.admin.getPhone())
                .email(this.admin.getEmail())
                .password(this.admin.getPassword())
                .build();
    }
}
